<?php
namespace Cyfy\Modules\Users\Forms;

use \Cyfy\Message;
use \Cyfy\Modules\Forms;
use \Cyfy\Modules\Users\Current;
use \Cyfy\Modules\Users\Module;

/**
 * User login form.
 *
 * @author Dandelion <dandelion8888@gmail.com>
 * @version 0.1
 */
class Login extends Forms\Form
{

    function structure()
    {
        $this -> action = 'user';

        $i = new Forms\TextBox('username', self :: t(30));
        $i -> required = true;
        $i -> maxLength = 50;
        $this -> addItem($i);

        $i = new Forms\TextBox('password', self :: t(40));
        $i -> required = true;
        $i -> password = true;
        $i -> maxLength = 50;
        $this -> addItem($i);

        $b = new Forms\Button(self :: t(110));
        $this -> addButton($b);
    }

    function validate()
    {
        return Current :: login($this -> get('username'), $this -> get('password'));
    }

    function submit()
    {
        return true;
    }

}
